import 'package:flutter/material.dart';
import 'package:shining_red_star/definitions/app.dart';
import '../widgets/app_icon.dart';
import '../widgets/auto_grid.dart';
import '../wrappers/safe-area.dart';

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return SafeAreaPageWrapper(
      padding: EdgeInsets.all(16),
      child: AutoGrid(
        expectItemWidth: 80,
        expectItemHeight: 96,
        mainAxisSpacing: 10,
        crossAxisSpacing: 10,
        children: miniAppList.map((item) {
          return AppIcon(
            autofocus: item.id == AppId.pictorial,
            name: item.name,
            icon: item.avatar,
            backgroundColor: item.backgroundColor,
            onConfirm: () {
              Navigator.pushNamed(context, item.routerKey.name);
            },
          );
        }).toList(),
      ),
    );
  }
}
